package com.sxhuayuan.parking.dao;

import com.sxhuayuan.parking.entity.ParkingInOut;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;

public interface ParkingInOutDao extends BaseDao<ParkingInOut, Long> {

	ParkingInOut findByUniqueId(Long uniqueId);

    ParkingInOut findByParkingLotIdAndLotRecordId(Long lotId, String recordId);
    
    @Query(nativeQuery = true, value = "select count(1) from hypk_parking_in_out where parking_lot_id = ?1 and lot_record_id = ?2")
    int countByParkingLotIdAndRecordId(Long lotId, String  recordId);
    
    ParkingInOut findByInTimeAndParkingLotIdAndCarPlate(Date inTime, Long parkId, String carPlate);

    @Query(nativeQuery = true, value = "select * from hypk_parking_in_out where parking_lot_id = ?1 and car_plate = ?2 order by out_time desc limit 1")
    ParkingInOut findByParkingLotIdAndCarPlateOne(Long lotId, String  carPlate);
}
